package com.lws.systembarsample

import android.app.Activity
import android.content.Intent
import android.os.Bundle
import android.widget.Button
import androidx.appcompat.app.AppCompatActivity
import androidx.core.view.ViewCompat
import androidx.core.view.WindowCompat
import androidx.core.view.WindowInsetsControllerCompat

class MainActivity : AppCompatActivity() {
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_main)

        WindowCompat.setDecorFitsSystemWindows(window, false)


        findViewById<Button>(R.id.pureBackground).setOnClickListener {
            startActivity(Intent(this, PureColourBackgroundActivity::class.java))
        }

        findViewById<Button>(R.id.noInset).setOnClickListener {
            startActivity(Intent(this, FullScreenNoInsetActivity::class.java))
        }

        findViewById<Button>(R.id.setPadding).setOnClickListener {
            startActivity(Intent(this, FullScreenPaddingActivity::class.java))
        }

        findViewById<Button>(R.id.setMargin).setOnClickListener {
            startActivity(Intent(this, FullScreenMarginActivity::class.java))
        }

    }
}


fun setLightNavigationBar(activity: Activity) {
    val view = activity.window.decorView

    //设置亮色状态栏（状态栏图标暗色）仅在APi >= 23 时有效
    ViewCompat.getWindowInsetsController(view)?.isAppearanceLightStatusBars = true

    //设置暗色状态栏（状态栏图标亮色）仅在APi >= 23 时有效
    ViewCompat.getWindowInsetsController(view)?.isAppearanceLightStatusBars = false


    //设置亮色导航栏（导航栏图标暗色）仅在APi >= 26 时有效
    ViewCompat.getWindowInsetsController(view)?.isAppearanceLightNavigationBars = true

    //设置暗色状态栏（状态栏图标亮色）仅在APi >= 26 时有效
    ViewCompat.getWindowInsetsController(view)?.isAppearanceLightNavigationBars = false

}